package com.ln.第二遍1027.demo005;

import java.lang.reflect.Method;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/10/27 17:31
 */
public class Test005 {
    public static void main(String[] args) throws Exception{
        Class<Pig> pigClass = Pig.class;
        Method wu = pigClass.getDeclaredMethod("wu", String.class, int.class);
        Pig pig = pigClass.newInstance();
        Object invoke = wu.invoke(pig,"哈哈",10);
        System.out.println("invoke = " + invoke);

        Method ke = pigClass.getDeclaredMethod("ke");
        Object invoke1 = ke.invoke(pig);
        System.out.println("invoke1 = " + invoke1);
    }
}
class Cat{
    public void show(){
        System.out.println("猫的show方法");
    }
    private void hei(){
        System.out.println("猫的hei方法");
    }
}
class Pig extends Cat {
    public Integer ke(){
        System.out.println("猪的ke方法");
        return 200;
    }
    public void wu(String name,int age){
        System.out.println("猪的wu方法");
    }
}
